/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package g5.fw;

import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author hue
 * @param <T>
 */
public class HBox<T extends IJSon> {
    private T left;
    private T right;
    private T both;
    
    public HBox(T left, T right, T both) {
        this.left = left;
        this.right = right;
        this.both = both;
    }
    
    public T getLeft() {
        return left;
    }

    public T getRight() {
        return right;
    }

    public T getBoth() {
        return both;
    }
    
    public JSONObject toJSON() throws JSONException {
        JSONObject jsObj = new JSONObject();
        if(left != null) {
            jsObj.put("left", left.toJSON());
        }
        if(right != null) {
            jsObj.put("right", right.toJSON());
        }
        if(both != null) {
            jsObj.put("both", both.toJSON());
        }
        
        return jsObj;
    }

    @Override
    public String toString() {
        return "{Left=" + (left!=null) + "},{Right=" + (right!=null) + "},{Both=" + (both!=null) + "}";
    }
}
